from rest_framework.generics import ListAPIView,CreateAPIView
from rest_framework.response import Response

from goods.views import SKU
from meiduo_admin.serialziers.goodsmange import SkuSerializer
from meiduo_admin.utils import PageNum
class GoodsMangeView(ListAPIView):
    """
    获取商品数据

    """
    #指定查询集
    queryset =SKU.objects.all().order_by('id')
    #指定序列化器
    serializer_class = SkuSerializer
    #指定分页器
    pagination_class = PageNum

    ##重写获取查询集数据的方法
    def get_queryset(self):
        if self.request.query_params.get('keyword') == '':
            return SKU.objects.all()
        else:
            return SKU.objects.filter(name=self.request.query_params.get('keyword'))